package cn.dnui_jzy913.dnuifood_16110100913.Fragment;

import android.annotation.TargetApi;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import java.util.List;

import cn.dnui_jzy913.dnuifood_16110100913.bean.CommentsBean;
import cn.dnui_jzy913.dnuifood_16110100913.bean.ShopBean;
import cn.dnui_jzy913.dnuifood_16110100913.bean.UserCollection;

public abstract class BaseFragment extends android.support.v4.app.Fragment {
    private SharedPreferences sp;
    protected android.support.v4.app.FragmentManager childManager;
    protected android.support.v4.app.FragmentTransaction transaction;
    protected Context context;//:Activity、Service、Application的父类
    protected RecyclerView recyclerView;
    protected View view=null;
    abstract void initViews();
    abstract void initData();
    abstract void initEvents();
    protected abstract int initlayout();
    public BaseFragment(){
        context = getActivity();
    }
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(initlayout(),container,false);
        initViews();
        initData();
        initEvents();
        return view;
    }
    public String getUser_id(){
        sp = getActivity().getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getString("user_id","");
    }
    public String getUser_password(){
        sp = getActivity().getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getString("userpass","");
    }
    public void showToast(String msg){
        Toast.makeText(getActivity(),msg,Toast.LENGTH_LONG).show();
    }

}